import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;

/**
 * @Author quan
 * @Description 简单了解Jackson
 * @Date 2023/6/23 19:53
 */
public class Demo2_JacksonTest {
    public static void main(String[] args) throws JsonProcessingException {
        //创建一个objectMapper对象
        ObjectMapper objectMapper = new ObjectMapper();
        HashMap<String,Object> map = new HashMap<String, Object>();
        map.put("code",200);
        map.put("msg","成功");
        map.put("data","hello,jackson");
        //将对象转化为json字符串
        String jsonStr = objectMapper.writeValueAsString(map);
        System.out.println(jsonStr);
        //将json字符串转化为对象
//        objectMapper.readValue();
    }
}
